#ifndef WF_DRAWLINEANGLE_H
#define WF_DRAWLINEANGLE_H

#include "pf_previewactioninterface.h"
#include "pf_line.h"
#include "gui_export.h"

/**
 * This action class can handle user events to draw 
 * simple lines at a gien angle.
 *
 */
class GUI_EXPORT WF_DrawLineAngle : public PF_PreviewActionInterface {
	Q_OBJECT
public:
    /**
     * Action States.
     */
    enum Status {
        SetPos,       /**< Setting the position.  */
		SetAngle,     /**< Setting angle in the command line. */
		SetLength     /**< Setting length in the command line. */
    };
	
    WF_DrawLineAngle(PF_Container& container,
                           PF_GraphicView& graphicView,
                           double angle=0.0,
                           bool fixedAngle=false);
    ~WF_DrawLineAngle();

	static QAction* createGUIAction(LX_Define::ActionType type, QObject* /*parent*/);
	
	virtual LX_Define::ActionType rtti() {
		return LX_Define::ActionDrawLineAngle;
	}

    void reset();

    virtual void init(int status=0);
	
    virtual void trigger();

    virtual void mouseMoveEvent(PF_MouseEvent* e);
    virtual void mouseReleaseEvent(PF_MouseEvent* e);
	void preparePreview();
	
	virtual void coordinateEvent(PF_CoordinateEvent* e);
    virtual void commandEvent(PF_CommandEvent* e);
	virtual PF_StringList getAvailableCommands();
	
    virtual void hideOptions();
    virtual void showOptions();

    virtual void updateMouseButtonHints();
    virtual void updateMouseCursor();
    virtual void updateToolBar();

	void setSnapPoint(int sp) {
		snpPoint = sp;
	}

	int getSnapPoint() {
		return snpPoint;
	}

	void setAngle(double a) {
		angle = a;
	}

	double getAngle() {
		return angle;
	}

	void setLength(double l) {
		length = l;
	}

	double getLength() {
		return length;
	}

	bool hasFixedAngle() {
		return fixedAngle;
	}

protected:
    /**
     * Line data defined so far.
     */
    PF_LineAttribute data;
	/**
	 * Position.
	 */
	PF_Vector pos;
    /**
     * Line angle.
     */
    double angle;
	/**
	 * Line length.
	 */
	double length;
    /**
     * Is the angle fixed?
     */
    bool fixedAngle;
    /**
     * Snap point (start, middle, end).
     */
    int snpPoint;
};

#endif

